package popcorn.ticket.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import popcorn.ticket.entity.Logs;
import popcorn.ticket.service.LogsService;
import popcorn.ticket.tool.PageData;

@Controller
public class LogController {

	@Autowired
	private LogsService ls;
	
	Logger logger = Logger.getLogger(LogController.class);

	/**
	 * 根据用户编号加时间区间查询
	 * @param userid 用户编号
	 * @param page  页码
	 * @param limit 每页的个数
	 * @param startTime 时间区间的开始时间
	 * @param endTime 时间区间的结束
	 * @return
	 */
	@RequestMapping(value = "slbu", produces = "application/json;charset = utf-8")
	@ResponseBody
	public PageData<Logs> selectLogsByUserid(@RequestParam(value = "userid", defaultValue = "0") int userid,
			@RequestParam(value = "page", defaultValue = "1") int page,
			@RequestParam(value = "limit", defaultValue = "10") int limit,
			@RequestParam(value = "startTime", defaultValue = "") String startTime,
			@RequestParam(value = "endTime", defaultValue = "") String endTime) {
		logger.debug("start:"+startTime);
		logger.info("end:"+endTime);
		
		PageData<Logs> pd = ls.selectLogsByUserid(userid, page, limit, startTime, endTime);
		return pd;
	}

}
